<?php
class ti_util
{
	function swap($string,$swap)
	{
		if(get_class($swap) == 'ti_query')
		{
			$swap = $swap->data;
		}
		foreach($swap as $key=>$value)
		{
			$string = str_replace('{'.$key.'}',$value,$string);
		}
		return $string;
	}
	
	function db_swap($string,$swap=null)
	{
		global $ti;
		if(is_array($swap))
		{
			foreach($swap as $key=>$value)
			{
				if(is_string(value))
				{
					$value = "'".$ti->config['database.escape']($value)."'";
				}
				$string = str_replace('{'.$key.'}',$value,$string);
			}
		}
		return $string;
	}
}
?>